Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
Why is ESLint complaining about a syntax error when I can run my code fine in Node? "Parsing error: Unexpected token ="

I have looked around in Stackoverflow and the ESLint docs for an answer, but most are not what I need since they pertain to React.

I am using Node v14.17.0, and ESLint v7.32.0 as a dev dependency. I have the following piece of code.

class Service {
  constructor(){
    this.numbers = [1,2,3];
  }

  doAnotherThing = () => {
    console.log("I do the thing after 100 millis", this.numbers);
  }
  
  doSomething(){
    setTimeout(this.doAnotherThing, 100);
  }
}

let service = new Service();
service.doSomething();

Simply running node test.js runs the application fine and I get the expected result printed to STDOUT.

All sounds good, let me add ESLint and the eslint config file.

{
  "env": {
      "node": true,
      "mocha": true
  },
  "extends": "eslint:recommended",
  "parserOptions": {
      "ecmaVersion": "latest"
  },
}

Now run when I run eslint on the file, I get the following error.

/test.js
  2:10  error  Parsing error: Unexpected token =

Keep in mind I am NOT using Babel or any transpiling, so do I need to specify a variable or something in the config? Why is this error happening and why does installing @babel/eslint-parser solve the issue? I am not using Babel at all. Is this a limit to ESLint or simply something I don't understand?

Using a regular method(){} does NOT work and is not the solution since I lose the this.number value. See: https://jsfiddle.net/0crpx6bv

Reading around I see a lot of React and NONE Node.js solutions. This is plain Node without Babel and not in React.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!